<?xml version="1.0" encoding="ISO-8859-1"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:a="http://www.andromda.org/cartridges/jsf"
      xmlns:tr="http://myfaces.apache.org/trinidad"
      xmlns:ajsfc="http://www.andromda.org/cartridges/jsf/facelets"
      >

<ui:composition template="/layout/layout.xhtml">
    <ui:param name="partialTriggers" value="#{fn:split(':manageLocationForm_search:newAction :manageLocationForm_search:searchResult:loadAction :manageLocationForm_edit:saveAction :manageLocationForm_edit:saveAndNewAction :manageLocationForm_edit:cancelAction',' ')}"/>
    <ui:param name="usesUpload" value="false"/>
    <ui:define name="title">
        <c:set var="title" value="#{messages['location.view.title']}#{messages['title.action.separator']}#{messages[manageLocationForm.editState ? (empty manageLocationForm.id ? 'title.action.new' : 'title.action.edit') : 'title.action.search']}" scope="request"/>
    </ui:define>
    <ui:define name="content">
        <tr:panelGroupLayout layout="vertical" inlineStyle="display:#{manageLocationForm.editState?'none':''}">
        <tr:subform id="manageLocationForm_search">
        <tr:panelFormLayout>
        <tr:inputText id="searchForm_uniqueCode" value="#{manageLocationForm.searchForm.uniqueCode}" label="#{messages['location.unique.code']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:inputText id="searchForm_locationName" value="#{manageLocationForm.searchForm.locationName}" label="#{messages['location.location.name']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:selectOneChoice id="searchForm_status" value="#{manageLocationForm.searchForm.status}" label="#{messages['location.status']}:" required="false" readOnly="false" unselectedLabel="">
            <f:converter converterId="com.systemsjr.jrbase.location.LocationStatus"/>
            <f:selectItems value="#{ajsfc:getEnumSelectItems('location.status.','com.systemsjr.jrbase.location.LocationStatus')}"/>
        </tr:selectOneChoice>
        <tr:selectOneChoice id="searchForm_type" value="#{manageLocationForm.searchForm.type}" label="#{messages['location.type']}:" required="false" readOnly="false" unselectedLabel="">
            <f:converter converterId="com.systemsjr.jrbase.location.Type"/>
            <f:selectItems value="#{ajsfc:getEnumSelectItems('type.','com.systemsjr.jrbase.location.Type')}"/>
        </tr:selectOneChoice>
        <tr:inputText id="searchForm_levelCode" value="#{manageLocationForm.searchForm.levelCode}" label="#{messages['location.level.code']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:inputText id="searchForm_description" value="#{manageLocationForm.searchForm.description}" label="#{messages['location.description']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:selectManyListbox id="searchForm_individualOwners" value="#{manageLocationForm.searchForm.individualOwners}" label="#{messages['location.individual.owners']}:" required="false" readOnly="false" size="3">
            <c:if test="${!empty manageLocationForm.individualOwnersBackingList}">
                <c:forEach var="row" items="#{manageLocationForm.individualOwnersBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectManyListbox>
        <tr:selectManyListbox id="searchForm_locationOrganisations" value="#{manageLocationForm.searchForm.locationOrganisations}" label="#{messages['location.location.organisations']}:" required="false" readOnly="false" size="3">
            <c:if test="${!empty manageLocationForm.locationOrganisationsBackingList}">
                <c:forEach var="row" items="#{manageLocationForm.locationOrganisationsBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectManyListbox>
        <tr:selectManyListbox id="searchForm_loginSessions" value="#{manageLocationForm.searchForm.loginSessions}" label="#{messages['location.login.sessions']}:" required="false" readOnly="false" size="3">
            <c:if test="${!empty manageLocationForm.loginSessionsBackingList}">
                <c:forEach var="row" items="#{manageLocationForm.loginSessionsBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectManyListbox>
        <tr:selectOneChoice id="searchForm_fallsWithinArea" value="#{manageLocationForm.searchForm.fallsWithinArea}" label="#{messages['location.falls.within.area']}:" required="false" readOnly="false" unselectedLabel="">
            <c:if test="${!empty manageLocationForm.fallsWithinAreaBackingList}">
                <c:forEach var="row" items="#{manageLocationForm.fallsWithinAreaBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectOneChoice>
        <tr:selectManyListbox id="searchForm_individuals" value="#{manageLocationForm.searchForm.individuals}" label="#{messages['location.individuals']}:" required="false" readOnly="false" size="3">
            <c:if test="${!empty manageLocationForm.individualsBackingList}">
                <c:forEach var="row" items="#{manageLocationForm.individualsBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectManyListbox>
        <tr:selectOneChoice id="searchForm_locationType" value="#{manageLocationForm.searchForm.locationType}" label="#{messages['location.location.type']}:" required="false" readOnly="false" unselectedLabel="">
            <c:if test="${!empty manageLocationForm.locationTypeBackingList}">
                <c:forEach var="row" items="#{manageLocationForm.locationTypeBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectOneChoice>
        <tr:selectManyListbox id="searchForm_locations" value="#{manageLocationForm.searchForm.locations}" label="#{messages['location.locations']}:" required="false" readOnly="false" size="3">
            <c:if test="${!empty manageLocationForm.locationsBackingList}">
                <c:forEach var="row" items="#{manageLocationForm.locationsBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectManyListbox>
        <f:facet name="footer">
            <tr:panelButtonBar>
                <tr:commandButton id="searchAction" text="#{messages['action.search']}" action="#{locationController.search}" accessKey="#{messages['action.search.access.key']}" partialSubmit="true"/>
                <tr:commandButton id="newAction" text="#{messages['action.new']}" action="#{locationController.startNew}" accessKey="#{messages['action.new.access.key']}" partialSubmit="true" immediate="true"/>
            </tr:panelButtonBar>
        </f:facet>
        </tr:panelFormLayout>
        <tr:spacer width="1" height="10"/>
        <tr:table id="searchResult" allDetailsEnabled="true" var="row" rowBandingInterval="1" value="#{manageLocationForm.manageableList}" rows="#{preferences.maxTableRows}" width="90%" inlineStyle="display:#{manageLocationForm.manageableList == null? 'none': ''}" partialTriggers="searchResult:deleteAction ::searchAction">
            <f:facet name="footer">
                <h:panelGroup>
                    <tr:outputText value="#{fn:length(manageLocationForm.manageableList)}">
                        <f:convertNumber groupingUsed="true"/>
                    </tr:outputText>
                    <tr:spacer width="10" height="1"/>
                    <tr:outputText value="#{messages['records.found']}"/>
                </h:panelGroup>
                <h:panelGroup style="width:100%;font-weight:normal">
                    <tr:outputText value="#{fn:length(manageLocationForm.manageableList)}" inlineStyle="display:#{empty manageLocationForm.manageableList?'none':''}">
                        <f:convertNumber groupingUsed="true"/>
                    </tr:outputText>
                    <tr:spacer width="10" height="1" inlineStyle="display:#{empty manageLocationForm.manageableList?'none':''}"/>
                    <tr:outputText value="#{messages['records.found']}" inlineStyle="display:#{empty manageLocationForm.manageableList?'none':''}"/>
                    <tr:outputText value="#{messages['empty.result.set']}" inlineStyle="display:#{empty manageLocationForm.manageableList?'':'none'}"/>
                </h:panelGroup>
            </f:facet>
            <tr:column width="46px">
                <f:facet name="header">
                    <h:panelGroup>
                        <tr:commandLink action="#{locationController.odsExport}" inlineStyle="display:#{empty manageLocationForm.manageableList?'none':''}">
                            <tr:image source="/images/spreadsheet.png" shortDesc="#{messages['export.spreadsheet']}" inlineStyle="border-style:none" />
                        </tr:commandLink>
                    </h:panelGroup>
                </f:facet>
                <h:panelGroup>
                    <tr:commandLink id="loadAction" actionListener="#{locationController.load}" partialSubmit="true" immediate="true">
                       <tr:image source="/images/tableLoad.gif" shortDesc="#{messages['action.load']}" inlineStyle="border-style:none" />
                       <f:param name="id" id="id" value="#{row.id}" />
                    </tr:commandLink>
                    <tr:spacer width="10" height="1"/>
                    <tr:commandLink id="deleteAction" actionListener="#{locationController.delete}" partialSubmit="true" immediate="true">
                        <tr:image source="/images/tableDelete.gif" shortDesc="#{messages['action.delete']}" inlineStyle="border-style:none" />
                        <f:param name="id" id="id" value="#{row.id}" />
                    </tr:commandLink>
                </h:panelGroup>
            </tr:column>
            <tr:column sortable="true" sortProperty="uniqueCode">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.unique.code']}"/>
                </f:facet>
                <tr:outputText value="#{row.uniqueCode}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="locationName">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.location.name']}"/>
                </f:facet>
                <tr:outputText value="#{row.locationName}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="status">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.status']}"/>
                </f:facet>
                <tr:outputText value="#{ajsfc:getEnumMessage('location.status.',row.status)}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="type">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.type']}"/>
                </f:facet>
                <tr:outputText value="#{ajsfc:getEnumMessage('type.',row.type)}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="levelCode">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.level.code']}"/>
                </f:facet>
                <tr:outputText value="#{row.levelCode}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="description">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.description']}"/>
                </f:facet>
                <tr:outputText value="#{row.description}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="false">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.view.title']}"/>
                </f:facet>
                <tr:outputText value="#{row.fallsWithinArea}" converter="com.systemsjr.jrbase.location.crud.LocationJsfConverter"/>
            </tr:column>
            <tr:column sortable="false">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.type.view.title']}"/>
                </f:facet>
                <tr:outputText value="#{row.locationType}" converter="com.systemsjr.jrbase.location.crud.LocationTypeJsfConverter"/>
            </tr:column>
        </tr:table>
        </tr:subform>
        </tr:panelGroupLayout>
        <tr:panelGroupLayout layout="vertical" inlineStyle="display:#{manageLocationForm.editState?'':'none'}">
        <tr:subform id="manageLocationForm_edit" >
            <tr:panelFormLayout>
        <tr:inputText id="uniqueCode" value="#{manageLocationForm.uniqueCode}" label="#{messages['location.unique.code']}:" required="true" readOnly="false">
        </tr:inputText>
        <tr:inputText id="locationName" value="#{manageLocationForm.locationName}" label="#{messages['location.location.name']}:" required="true" readOnly="false">
        </tr:inputText>
            <tr:selectOneChoice id="status" value="#{manageLocationForm.status}" label="#{messages['location.status']}:" required="true" readOnly="false" unselectedLabel="">
                <f:converter converterId="com.systemsjr.jrbase.location.LocationStatus"/>
                <f:selectItems value="#{ajsfc:getEnumSelectItems('location.status.','com.systemsjr.jrbase.location.LocationStatus')}"/>
            </tr:selectOneChoice>
            <tr:selectOneChoice id="type" value="#{manageLocationForm.type}" label="#{messages['location.type']}:" required="true" readOnly="false" unselectedLabel="">
                <f:converter converterId="com.systemsjr.jrbase.location.Type"/>
                <f:selectItems value="#{ajsfc:getEnumSelectItems('type.','com.systemsjr.jrbase.location.Type')}"/>
            </tr:selectOneChoice>
        <tr:inputText id="levelCode" value="#{manageLocationForm.levelCode}" label="#{messages['location.level.code']}:" required="true" readOnly="false">
        </tr:inputText>
        <tr:inputText id="description" value="#{manageLocationForm.description}" label="#{messages['location.description']}:" required="false" readOnly="false">
        </tr:inputText>
            <tr:inputHidden id="id" value="#{manageLocationForm.id}"/>
            <tr:selectManyListbox id="individualOwners" value="#{manageLocationForm.individualOwners}" label="#{messages['location.individual.owners']}:" required="false" readOnly="false" size="3">
                   <c:if test="${!empty manageLocationForm.individualOwnersBackingList}">
                       <c:forEach var="row" items="#{manageLocationForm.individualOwnersBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectManyListbox>
            <tr:selectManyListbox id="locationOrganisations" value="#{manageLocationForm.locationOrganisations}" label="#{messages['location.location.organisations']}:" required="false" readOnly="false" size="3">
                   <c:if test="${!empty manageLocationForm.locationOrganisationsBackingList}">
                       <c:forEach var="row" items="#{manageLocationForm.locationOrganisationsBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectManyListbox>
            <tr:selectManyListbox id="loginSessions" value="#{manageLocationForm.loginSessions}" label="#{messages['location.login.sessions']}:" required="false" readOnly="false" size="3">
                   <c:if test="${!empty manageLocationForm.loginSessionsBackingList}">
                       <c:forEach var="row" items="#{manageLocationForm.loginSessionsBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectManyListbox>
            <tr:selectOneChoice id="fallsWithinArea" value="#{manageLocationForm.fallsWithinArea}" label="#{messages['location.falls.within.area']}:" required="false" readOnly="false" unselectedLabel="">
                   <c:if test="${!empty manageLocationForm.fallsWithinAreaBackingList}">
                       <c:forEach var="row" items="#{manageLocationForm.fallsWithinAreaBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectOneChoice>
            <tr:selectManyListbox id="individuals" value="#{manageLocationForm.individuals}" label="#{messages['location.individuals']}:" required="false" readOnly="false" size="3">
                   <c:if test="${!empty manageLocationForm.individualsBackingList}">
                       <c:forEach var="row" items="#{manageLocationForm.individualsBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectManyListbox>
            <tr:selectOneChoice id="locationType" value="#{manageLocationForm.locationType}" label="#{messages['location.location.type']}:" required="true" readOnly="false" unselectedLabel="">
                   <c:if test="${!empty manageLocationForm.locationTypeBackingList}">
                       <c:forEach var="row" items="#{manageLocationForm.locationTypeBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectOneChoice>
            <tr:selectManyListbox id="locations" value="#{manageLocationForm.locations}" label="#{messages['location.locations']}:" required="false" readOnly="false" size="3">
                   <c:if test="${!empty manageLocationForm.locationsBackingList}">
                       <c:forEach var="row" items="#{manageLocationForm.locationsBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectManyListbox>

            <f:facet name="footer">
                   <tr:panelButtonBar>
                       <tr:commandButton id="saveAction" text="#{messages['action.save']}" action="#{locationController.save}" accessKey="#{messages['action.save.access.key']}" partialSubmit="false"/>
                       <tr:commandButton id="saveAndNewAction" text="#{messages['action.saveAndNew']}" action="#{locationController.saveAndNew}" accessKey="#{messages['action.saveAndNew.access.key']}" inlineStyle="display:#{(empty manageLocationForm.id)?'':'none'}" partialSubmit="false"/>
                       <tr:commandButton id="cancelAction" text="#{messages['action.cancel']}" action="#{locationController.cancel}" accessKey="#{messages['action.cancel.access.key']}" immediate="true" partialSubmit="true" />
                   </tr:panelButtonBar>
            </f:facet>
            </tr:panelFormLayout>
        </tr:subform>
        </tr:panelGroupLayout>
    </ui:define>
</ui:composition>

</html>
